//排序加双指针 N2
let nums = [24,3,82,22,35,84,19]
var triangleNumber = function(nums) {
    nums.sort((a,b)=>a-b)
    let ans = 0
    for(let i=0;i<nums.length-1;i++){
        let k =i+1
        for(let j=i+1;j<nums.length;j++){
            while(nums[k+1]<nums[j]+nums[i]){
                k++
            }
            ans = ans+k-j
        }
    }
    return ans
} 
console.log(triangleNumber(nums));
